package com.jiangjiang.eshop.wms.service;

import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import com.baomidou.mybatisplus.core.toolkit.Wrappers;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.jiangjiang.eshop.wms.convert.SaleDeliveryOrderSendOutDetailConvert;
import com.jiangjiang.eshop.wms.dao.SaleDeliveryOrderSendOutDetailMapper;
import com.jiangjiang.eshop.wms.domain.SaleDeliveryOrderSendOutDetail;
import com.jiangjiang.eshop.wms.dto.SaleDeliveryOrderSendOutDetailDTO;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.context.annotation.Lazy;
import org.springframework.stereotype.Service;

import java.util.List;
import java.util.Set;

/**
 * @Author Jianghaowen
 * @Date 2021/9/17
 * @Description: TODO
 * @Version V1.0
 **/
@Service
public class SaleDeliveryOrderSendOutDetailService extends ServiceImpl<SaleDeliveryOrderSendOutDetailMapper, SaleDeliveryOrderSendOutDetail> {

    @Autowired
    private SaleDeliveryOrderSendOutDetailConvert saleDeliveryOrderSendOutDetailConvert;

    /**
     * 批量保存发货条目数据
     * @param sendOutItems 发货条目数据
     */
    public Boolean saveBatch(List<SaleDeliveryOrderSendOutDetailDTO> sendOutItems) {
      return  this.saveBatch(saleDeliveryOrderSendOutDetailConvert.convertDTOList2Entities(sendOutItems));
    }


    /**
     * 根据销售出库明细id集合获取发货明细
     * @param saleDeliveryOrderItemIds 销售出库明细id集合
     * @return 查询结果
     */
    public List<SaleDeliveryOrderSendOutDetailDTO> queryAllBySaleDeliveryOrderItemIds(Set<Long> saleDeliveryOrderItemIds) {
        LambdaQueryWrapper<SaleDeliveryOrderSendOutDetail> wrapper = Wrappers.lambdaQuery();
        wrapper.in(SaleDeliveryOrderSendOutDetail::getSaleDeliveryOrderItemId, saleDeliveryOrderItemIds);
        return saleDeliveryOrderSendOutDetailConvert.convertEntities2DTOList(this.list(wrapper));
    }

}
